/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hotelinteligente.vista;

import java.io.File;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;

/**
 *
 * @author vero
 */
public class Sonido {

    private static String SONIDO_ALERTA= "/home/matias/NetBeansProjects/trunk/HotelInteligente/src/hotelinteligente/vista/sounds/atencion.wav";
    private static String SONIDO_INCENDIO= "/home/matias/NetBeansProjects/trunk/HotelInteligente/src/hotelinteligente/vista/sounds/alarma-de-incendios.wav";

    private Clip clip;

    public void reproducirAlerta() {
        try {
            clip= AudioSystem.getClip();
            AudioInputStream audio= AudioSystem.getAudioInputStream(new File(SONIDO_ALERTA));
            clip.open(audio);
            clip.loop(Integer.MAX_VALUE);
        } catch(Exception ex){
            System.err.println( ex.getMessage() );
        }
    }
    
    public void reproducirAlertaIncendio() {
        try {
            clip= AudioSystem.getClip();
            AudioInputStream audio= AudioSystem.getAudioInputStream(new File(SONIDO_INCENDIO));
            clip.open(audio);
            clip.loop(Integer.MAX_VALUE);
        } catch(Exception ex){
            System.err.println( ex.getMessage() );
        }
    }

    public void stop() {
        clip.stop();
    }
}
